//
//  ELBasicViewController.swift
//  SinaWeiBo
//
//  Created by jiwang on 15/12/15.
//  Copyright © 2015年 jiwang. All rights reserved.
//

import UIKit

class ELBasicViewController: UITableViewController, ELBlankLogInViewDelegate {

    var logStatus = ELUserAccount.hasUserInfo
    
    override func loadView() {
        logStatus ? super.loadView() : setupDifferentView()
    }
    ///根据不同的控制器显示不同的title和图片
    private func setupDifferentView() {
        view = logView
        
        if self is ELMessageViewController {
            logView.setIconViewAndLabelWith("visitordiscover_image_message", titleName: "登录后,别人评论你的微博，发给你的消息，都会在这里显示")
        }else if self is ELDiscoverViewController {
            logView.setIconViewAndLabelWith("visitordiscover_image_message", titleName: "登录后，最新、最热的微博尽在掌握，紧跟潮流的步伐")
        }else if self is ELProfileViewController {
            logView.setIconViewAndLabelWith("visitordiscover_image_profile", titleName: "登录后,可以你的个性化设置尽在这里")
        }else if self is ELHomeViewController {
            //如果是主页页面的话 加载动画效果
            logView .IconaddAnimation()
        }
        
        addNavItem()
        logView.delegate = self
    }
    
    ///添加注册和登陆按钮
    private func addNavItem () {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registeClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    func registeClick() {
        print("点击注册")
    }
    
    func loginClick() {
        print("点击登录")
        let oauthVC = ELOauthViewController()
        
        self.presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
    
    lazy var logView : ELBlankLogInView = ELBlankLogInView()
    
}
